<?php
namespace Home\Controller;
use Think\Controller;
class DriveController extends Controller {
    public function index(){
    	$this->display();
    }
    public function getDriveList(){
    	$res = D('drive')->getDriveList();
    	if(!$res){
    		return ajaxReturn(0,'获取失败');
    	}
    	return ajaxReturn(1,'获取成功',$res);
    }
    public function insert(){
    	$this->display();
    }
    public function insertDriveInfo(){
    	if(!isset($_POST['drive_name']) || !$_POST['drive_name']){
    		return ajaxReturn(0,'传参失败');
    	}
    	$res = D('drive')->insertDriveInfo($_POST);
    	if(!$res){
    		return ajaxReturn(0,'添加失败');
    	}
    	return ajaxReturn(1,'添加成功');
    }
    public function revise(){
    	if(!isset($_GET['drive_id']) || !$_GET['drive_id']){
    		return ajaxReturn(0,'传参失败');
    	}
    	$res = D('drive')->getDriveInfo($_GET);
    	if(!$res){
    		return ajaxReturn(0,'添加失败');
    	}
    	$this->assign('drive',$res);
    	$this->display();
    }
    public function reviseDriveInfo(){
    	if(!isset($_POST) || !$_POST){
    		return ajaxReturn(0,'传参失败');
    	}
    	$cond['drive_id'] = $_POST['drive_id'];
    	$data['drive_name'] = $_POST['drive_name'];
    	$res = D('drive')->reviseDriveInfo($cond,$data);
    	if($res === false){
    		return ajaxReturn(0,'修改失败');
    	}
    	return ajaxReturn(1,'修改成功');
    }
}